<template>
	<view id="tmpl">
		<view class="container">
			<view class="title">{{ data.noticeTitle }}</view>
			<view class="detail">
				<text class="author">{{ data.updateBy }}</text>
				<text class="updateTime">{{ data.updateTime }}</text>
			</view>
			<!-- <view class="content"> -->
			<view><u-parse :content="content" @preview="preview" @navigate="navigate" /></view>
			<image :src="img" style="width: 500rpx;" @click="imga(img)"></image>
			<view @tap="getimg">
				
			</view>
		</view>
	</view>
</template>

<script>
import config from '../../static/common/config.js';
import uParse from '@/components/gaoyia-parse/parse.vue';

export default {
	components: {
		uParse
	},
	data() {
		return {
			type: 0,
			notice_id: 0,
			data: {},
			content: '',
			imageUrl: '',
			img:''
		};
	},
	methods: {
		preview(src, e) {},
		navigate(href, e) {},
		onLoad: function(query) {
			console.log(query)
			this.type = query.type;
			this.notice_id = query.notice_id;
		},

		getimg() {
			let src = document.getElementById('img').getElementsByTagName('img')[0].currentSrc;
			uni.previewImage({
				urls: [src],
				current: src
			});
		},
		imga(img){
			uni.previewImage({
				urls:[img],
				current:img
			})
		},
	
		onShow: function() {
			let _this = this;
			switch (Number(this.type)) {
				case 0:
					this.$api.xwxq(this.notice_id).then(res => {
						_this.$_if.FormatThumb(res.data.data, config, 'imageUrl');
						console.log('news', res);
						//_this.data.imageUrl =config+res.data.data.imageUrl

						_this.imageUrl = config + res.data.data.imageUrl;
						_this.data = res.data.data;
						console.log(_this.imageUrl);

						uni.setNavigationBarTitle({
							title: _this.data.noticeTitle
						});
						_this.content = _this.data.noticeContent.replace(/\<img/gi, '<img style="width:100%"');
					});
					break;
				case 1:
					this.$api.tgxx(this.notice_id).then(res => {
						console.log(res,'通报')
						_this.imageUrl = config + res.data.data.imageUrl;
						_this.data = res.data.data;
						// console.log('tg', res)
						_this.content = _this.data.tgContent.replace(/\<img/gi, '<img style="width:100%"');
					});
					break;
				case 2:
					this.$api.tbDetail(this.notice_id).then(res => {
						_this.data = res.data.data;
						_this.imageUrl = config + res.data.data.imageUrl;
						// console.log('tbDetail', res)
						uni.setNavigationBarTitle({
							title: _this.data.tbTitle
						});
						_this.content = _this.data.tbContent.replace(/\<img/gi, '<img style="width:100%"');
					});
					break;
				case 3:
					this.$api.qkxq(this.notice_id).then(res => {
						console.log('3',res)
						_this.data = res.data.data;
						_this.content = _this.data.noticeContent.replace(/\<img/gi, '<img style="width:100%"');
						_this.img = config+res.data.data.noticeFj
						console.log(_this.img)
						
					});
					break;
			}
		}
	}
};
</script>

<style lang="scss">
page {
	background-color: #fff;
}
.content {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}
.logo {
	height: 200rpx;
	width: 200rpx;
	margin-top: 200rpx;
	margin-left: auto;
	margin-right: auto;
	margin-bottom: 50rpx;
}

.container {
	padding: 40rpx;

	.title {
		font-size: 40rpx;
		font-weight: bold;
		line-height: 46rpx;
		letter-spacing: 5rpx;
	}
	.rich-text .richImg {
		width: 100%;
		height: auto;
	}

	.detail {
		color: #b3b3b3;
		margin-top: 10rpx;

		text {
			margin-right: 20rpx;
			line-height: 30rpx;
		}

		.author {
			font-size: $uni-font-size-base;
		}

		.updateTime {
			font-size: $uni-font-size-sm;
		}
	}

	.content {
		margin-top: 20rpx;

		overflow-y: auto;
		overflow-x: hidden;
		width: 700rpx;
		// 深度处理
		::v-deep img,
		::v-deep p,
		::v-deep span {
			width: 100% !important;
		}
	}
	image {
		// max-width: 100% !important;
		//max-height: 10% !important;
		// width: 50%;
	}
}
</style>
